package com.itheima.mapper;

import com.github.pagehelper.Page;
import com.itheima.pojo.Clazz;
import com.itheima.pojo.Result;
import org.apache.ibatis.annotations.*;
import org.springframework.web.bind.annotation.GetMapping;

import java.time.LocalDate;
import java.time.LocalTime;
import java.util.List;

@Mapper
public interface ClazzMapper {

    Page<Clazz> list(@Param("name") String name,
                     @Param("begin") LocalDate begin,
                     @Param("end") LocalDate end);

    //删除班级
    @Delete("delete from clazz where id=#{id}")
    void deleteById(Integer id);

    //添加班级
    @Insert("insert into clazz (name,room,begin_date,end_date,master_id,create_time, update_time) values (#{name},#{room},#{beginDate},#{endDate},#{masterId},#{createTime},#{updateTime})")
    void insert(Clazz clazz);

    //根据ID查询
    @Select("select * from clazz where id=#{id}")
    Clazz getById(Integer id);
    //修改班级
    //@Update("update clazz set name=#{name},room=#{room},begin_date=#{beginDate},end_date=#{endDate},master_id=#{masterId} where id=#{id}")
    void updateById(Clazz clazz);

    //查询所有班级
    @Select("select * from clazz order by update_time desc")
    List<Clazz> listAll();
}
